$(document).ready(function(){
	$('#user_form').submit(function(){
		return false;
	});
	$('#btn_change_password').click(function(){
		changePassword();
	});
	
});

function changePassword(){
	var oldpassword = $('#oldpassword').val();
	var password = $('#password').val();
	var repassword = $('#repassword').val();
	$('#submit_error').html('');
	if(password == repassword && password !== '' && oldpassword !==''){
		var data = {
			oldpassword: oldpassword,
			password: password
		};
		var request = {
			url: base_url + CHANGE_PASSWORD,
			type: 'POST',
			data: data,
			success: function(data){
				if(data == '400'){
					$('#submit_error').html(WRONG_PASSWORD);
				} else {
					$('#submit_error').html(RESPONSE_SUCCESS);
				}
			},
			error: function(error){
				$('#submit_error').html(RESPONSE_ERROR);
			}
		};
		excuteAjax(request);
	} else {
		$('#submit_error').html('Mật khẩu không trùng khớp');
	}
	$("html, body").animate({ scrollTop: 0 }, "slow");
}